home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form GopherS
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Gopher Sample"
- ClientHeight = 4635
- ClientLeft = 2160
- ClientTop = 2250
- ClientWidth = 9540
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 5040
- Left = 2100
- LinkTopic = "Form1"
- ScaleHeight = 4635
- ScaleWidth = 9540
- Top = 1905
- Width = 9660
- Begin VB.CommandButton cmdExit
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Cancel = -1 'True
- Caption = "E&xit"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 6960
- TabIndex = 3
- Top = 720
- Width = 2295
- End
- Begin VB.CommandButton cmdBack
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Go &Back"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 6960
- TabIndex = 1
- Top = 240
- Width = 2295
- End
- Begin VB.ListBox lstMenu
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 3930
- Left = 240
- TabIndex = 0
- Top = 480
- Width = 6375
- End
- Begin GopherLib.Gopher Gopher1
- Left = 9120
- Top = 4200
- _Version = 327680
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 64
- Blocking = -1 'True
- Host = "gopher.uiuc.edu"
- Port = 70
- Selector = ""
- Type = "1"
- OutputFilename = "C:\~~GOPHER.TXT"
- End
- Begin VB.Label Label2
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = $"gophers.frx":0000
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 3135
- Left = 6960
- TabIndex = 4
- Top = 1320
- Width = 2295
- End
- Begin VB.Label Label1
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "Current Menu:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 255
- Left = 240
- TabIndex = 2
- Top = 240
- Width = 2775
- End
- Attribute VB_Name = "GopherS"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- ' Storage for the Back button.
- Dim BackIndex
- Dim BackType(1 To 100) As String
- Dim BackHost(1 To 100) As String
- Dim BackPort(1 To 100) As Integer
- Dim BackSelector(1 To 100) As String
- Private Sub cmdBack_Click()
- ' If we don't have any sites in the back list,
- ' beep and exit, doing nothing.
- If BackIndex < 1 Then
- Beep
- Exit Sub
- End If
- ' Move to the new site and move back in the back list.
- NewSite BackHost(BackIndex), BackPort(BackIndex), BackType(BackIndex), BackSelector(BackIndex)
- BackIndex = BackIndex - 1
- End Sub
- Private Sub cmdExit_Click()
- Unload Me
- End Sub
- Private Sub Form_Load()
- Me.Caption = "Gopher Sample - " & Gopher1.Host & "\" & Gopher1.Selector
- ' Load the initial menu.
- Gopher1.Action = 1
- MenuLoad
- ' Nothing to go back to, yet.
- BackIndex = 0
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- ' Remove out temporary file (if any).
- On Error Resume Next
- Kill "C:\~~GOPHER.TXT"
- On Error GoTo 0
- End
- End Sub
- Private Sub lstMenu_DblClick()
- Dim ItemIndex As Integer
- ' Did the user click on an item in the menu?
- ' If not, beep and bail.
- If lstMenu.ListIndex < 0 Then
- Beep
- Exit Sub
- End If
- ' Get the index of the menu item from the list
- ' which acts as our menu. This index is
- ' stored in ItemData to allow us to sort
- ' the list (if desired).
- ItemIndex = lstMenu.ItemData(lstMenu.ListIndex)
- Select Case Gopher1.ItemType(ItemIndex)
- Case "0", "1", "7"
- Dim I
- ' If our Back list is full, drop an
- ' element from the list so that it
- ' won't overflow.
- If BackIndex >= 100 Then
- For I = 1 To 99
- BackType(I) = BackType(I + 1)
- BackHost(I) = BackHost(I + 1)
- BackPort(I) = BackPort(I + 1)
- BackSelector(I) = BackSelector(I + 1)
- Next I
- BackIndex = 99
- End If
- ' Save the current information for
- ' going back.
- BackIndex = BackIndex + 1
- BackType(BackIndex) = Gopher1.Type
- BackHost(BackIndex) = Gopher1.Host
- BackPort(BackIndex) = Gopher1.Port
- BackSelector(BackIndex) = Gopher1.Selector
- End Select
- NewSite Gopher1.ItemHost(ItemIndex), Gopher1.ItemPort(ItemIndex), Gopher1.ItemType(ItemIndex), Gopher1.ItemSelector(ItemIndex)
- End Sub
- Private Sub MenuLoad()
- Dim I
- ' Clear the user's menu.
- lstMenu.Clear
- ' Scan through all of the items in the Gopher menu.
- For I = 1 To Gopher1.ItemCount
- ' Put the current item into the user's menu
- ' based on the item's type.
- Select Case Gopher1.ItemType(I - 1)
- Case "0"
- lstMenu.AddItem "Text File: " & Gopher1.ItemDescription(I - 1)
- lstMenu.ItemData(lstMenu.NewIndex) = I - 1
- Case "1"
- lstMenu.AddItem "Menu: " & Gopher1.ItemDescription(I - 1)
- lstMenu.ItemData(lstMenu.NewIndex) = I - 1
- Case "7"
- lstMenu.AddItem "Search: " & Gopher1.ItemDescription(I - 1)
- lstMenu.ItemData(lstMenu.NewIndex) = I - 1
- Case Else
- lstMenu.AddItem "Unknown: " & Gopher1.ItemDescription(I - 1)
- lstMenu.ItemData(lstMenu.NewIndex) = I - 1
- End Select
- Next I
- End Sub
- Private Sub NewSite(ByVal Host As String, ByVal Port As Integer, ByVal MenuType As String, ByVal Selector As String)
- Dim Dummy
- Screen.MousePointer = 11
- On Error GoTo ErrorHandler
- Select Case MenuType
- Case "0"
- ' This item is a text file. Give the
- ' Gopher control the address info for the
- ' file.
- Gopher1.Host = Host
- Gopher1.Selector = Selector
- Gopher1.Type = MenuType
- Gopher1.Port = Port
- ' Load the text file. OutputFilename is
- ' set in the design envinronment, in this
- ' case. You can set the OutputFilename
- ' anytime you like.
- Gopher1.Action = 1
- Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
- Dummy = Shell("NOTEPAD.EXE " & Gopher1.OutputFilename, 1)
- Case "1"
- ' If this item is a menu, load the
- ' appropriate address into the Gopher
- ' control.
- Gopher1.Host = Host
- Gopher1.Selector = Selector
- Gopher1.Type = MenuType
- Gopher1.Port = Port
- ' Go to the new location and load the
- ' new menu into our list box.
- Gopher1.Action = 1
- Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
- MenuLoad
- Case "7"
- ' This is a search service. Point to it,
- ' get the word(s) to search from from the user,
- ' then load anything returned.
- Gopher1.Host = Host
- Gopher1.Type = MenuType
- Gopher1.Port = Port
- Gopher1.Selector = InputBox$("Enter a word or words to search for.", "Gopher Search")
- If Trim(Gopher1.Selector) <> "" Then
- Gopher1.Action = 1
- Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
- MenuLoad
- End If
- End Select
-
- Screen.MousePointer = 0
- Exit Sub
- ErrorHandler:
- Screen.MousePointer = 0
- MsgBox "Error " & Err & ": " & Error, 48, "Gopher Sample"
- Exit Sub
- End Sub
-